<%--
    Document   : racesContent
    Created on : Nov 23, 2012, 2:14:54 PM
    Author     : Mattysek
--%>

<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>

<s:useActionBean beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.RaceActionBean" var="actionBean"/>
<div class="txt">
    <h2><s:label for="race.list"/></h2>
</div>
<c:if test="${not empty pageContext.request.getParameter('error')}">
    <div class="error">
        <b><s:label for="error.${pageContext.request.getParameter('error')}"/></b>
    </div>
</c:if>
<c:if test="${pageContext.request.isUserInRole('ROLE_SUPERVISOR')}">
    <div class="raceForm">
        <tiles:insertDefinition name="dd-troops-web.races-createForm" />
    </div>
</c:if>
<ul class="raceList">
<c:forEach items="${actionBean.getRaces()}" var="race">
    <li class="raceThumbnail">
        <p class="raceName"><c:out value="${race.name}"/></p>
        <p>
            <c:choose>
                <c:when test="${race.description.length() < 75}">
                    <c:out value="${race.description}"/>
                </c:when>
                <c:otherwise>
                    <c:out value="${race.description.substring(0,73)}"/>...
                </c:otherwise>
            </c:choose>
        </p>
        <div class="raceBonuses">
            <s:label for="race.charisma"/>:&nbsp;<c:out value="${race.charisma}"/><br/>
            <s:label for="race.constitution"/>:&nbsp;<c:out value="${race.constitution}"/><br/>
            <s:label for="race.dexterity"/>:&nbsp;<c:out value="${race.dexterity}"/><br/>
            <s:label for="race.intelligence"/>:&nbsp;<c:out value="${race.intelligence}"/><br/>
            <s:label for="race.strength"/>:&nbsp;<c:out value="${race.strength}"/><br/>
            <s:label for="race.wisdom"/>:&nbsp;<c:out value="${race.wisdom}"/><br/>
        </div>
        <c:if test="${pageContext.request.isUserInRole('ROLE_SUPERVISOR')}">
            <div class="raceLinks">
                <s:link beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.RaceActionBean" event="delete"  class="delete">
                    <s:param name="race.getId()" value="${race.getId()}"/>
                    <img src="<%=request.getContextPath()%>/images/deleteIcon.gif"/>
                </s:link>
                <br/>
                <s:link beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.RaceActionBean" event="edit">
                    <s:param name="race.getId()" value="${race.getId()}"/>
                    <img src="<%=request.getContextPath()%>/images/editIcon.png"/>
                </s:link>
            </div>
        </c:if>
    </li>
</c:forEach>
</ul>
